package WaiBao;

import java.util.Arrays;

public class LiuYuYan {
    public static void main(String[] args) {
        String[] name = {"长安(班长)","赵科(团支书)", "小李(学习委员)","薛泽峰(卫生委员)", "凌俊杰(纪律委员)", "易学习", "李伟明", "张云博", "李奕可", "张天翼", "郝课", "吴金玉",
                "潘金莲", "薛宝才", "林黛玉", "刘姥姥", "李三娘", "李二牛", "王大壮", "刘峰", "李海", "萧敬腾", "張伯倫", "李涵", "张子涵", "王村乡", "张德贵", "赵富",
                "李昕", "刘昱妍(学生)"};//考生本人: 刘昱妍(学生)
        int[] age = {19, 20, 21, 18, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 19};//最后一位：考生年龄:19

        double[] jianya1 = {71, 79, 71, 86, 78, 79, 78, 80, 81, 91, 90, 87, 85, 79, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] jianya2 = {74, 76, 83, 83, 65, 74, 68, 99, 70, 70, 90, 77, 76, 84, 69, 65, 76, 70, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 95};
        double[] jianya3 = {72, 81, 81, 91, 74, 89, 78, 69, 81, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 96};

        double jingwen ;//代表每个学生的总分
        double kaikai;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            jingwen = jianya1[i] +jianya2[i] + jianya3[i];
//            kaikai= (jingwen * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + jingwen);
//            System.out.println(name[i] + "的平均分为:" + kaikai);
//        }

        double hauxue = 0,hauban = 0;

//        double[]  dapao = new double[30];
//        for (int i = 0; i < 30; i++) {
//            hauxue   = jianya1[i] + jianya2[i] +jianya3[i];
//            hauban  = (hauxue  * 1.0) / 3;
//            dapao [i] = hauban ;
//        }
//
//        for (int i = 0; i < dapao.length - 1; i++) {
//            for (int j = 0; j <  dapao .length - i - 1; j++) {
//                if (dapao [j] < dapao [j + 1]) {
//                    double tep = dapao[j];
//                    dapao[j] = dapao[j + 1];
//                    dapao[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(dapao[i]);
//        }



        double xiao1 = 0,  xiao2 = 0, xiao3 = 0;//计算每门课的平均分
        double yang1 = 0,yang2 = 0,yang3 = 0;//计算每门课标准差
        double tian1 = 0, tian2 = 0,tian3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < jianya1.length; i++) {
            he += jianya1[i];
        }
        xiao1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + xiao1);
        double Sum = 0;
        for (int i = 0; i <jianya2.length; i++) {
            Sum +=jianya2[i];
        }
        xiao2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + xiao2);
        double sum = 0;
        for (int i = 0; i <jianya3.length; i++) {
            sum +=jianya3[i];
        }
        xiao3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + xiao3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <jianya1.length; i++) {
            c1 += (jianya1[i] -  xiao1) * (jianya1[i] -xiao1);
        }
        yang1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + yang1);
        for (int i = 0; i < jianya2.length; i++) {
            c2 += (jianya2[i] - xiao2) * (jianya2[i] - xiao2);
        }
        yang2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +yang2);

        for (int i = 0; i <jianya3.length; i++) {
            c3 += (jianya3[i] - xiao3) * (jianya3[i] - xiao3);
        }
        yang3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + yang3);
//////////
////////
//        Arrays.sort(jianya1);
//        Arrays.sort(jianya2);
//        Arrays.sort(jianya3);
//        tian1 = (jianya1[14] + jianya1[15]) * 1.0 / 2;
//        tian2 = (jianya2[14] +jianya2[15]) * 1.0 / 2;
//        tian3 = (jianya3[14] +jianya3[15]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  tian1);
//        System.out.println("农业设施设计与制造的中位数为:" +  tian2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +  tian3);


    }
}
